/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package interfaz;

import java.io.Serializable;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import negocio.ui.uiClinica;

/**
 *
 * @author David
 */
public class NuevoExpedienteFrame_express extends javax.swing.JFrame implements Serializable{

    uiClinica ui = uiClinica.getInstance();
    
    /**
     * Creates new form NuevoExpedienteFrame_express
     */
    public NuevoExpedienteFrame_express() {
        this.pack();
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        Panel_nuevoExpediente = new javax.swing.JPanel();
        label_titulo = new javax.swing.JLabel();
        txt_nombre_expediente = new javax.swing.JTextField();
        label_nombre = new javax.swing.JLabel();
        label_apellidos = new javax.swing.JLabel();
        label_cedula = new javax.swing.JLabel();
        txt_apellidos_expediente = new javax.swing.JTextField();
        txt_cedula_expediente = new javax.swing.JTextField();
        btn_agregar_expediente = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        Menu_archivo = new javax.swing.JMenuItem();

        setTitle("Agregar Expediente");
        setForeground(java.awt.Color.white);
        setMaximumSize(new java.awt.Dimension(400, 300));
        setPreferredSize(new java.awt.Dimension(400, 250));
        setResizable(false);

        Panel_nuevoExpediente.setBackground(new java.awt.Color(255, 255, 255));
        Panel_nuevoExpediente.setMinimumSize(new java.awt.Dimension(390, 250));
        Panel_nuevoExpediente.setPreferredSize(new java.awt.Dimension(390, 250));
        Panel_nuevoExpediente.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        label_titulo.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
        label_titulo.setText("Nuevo Expediente");
        Panel_nuevoExpediente.add(label_titulo, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 0, -1, -1));
        Panel_nuevoExpediente.add(txt_nombre_expediente, new org.netbeans.lib.awtextra.AbsoluteConstraints(76, 73, 314, -1));

        label_nombre.setText("Nombre:");
        Panel_nuevoExpediente.add(label_nombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 76, 57, -1));

        label_apellidos.setText("Apellidos:");
        Panel_nuevoExpediente.add(label_apellidos, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 107, 62, -1));

        label_cedula.setText("Cedula:");
        Panel_nuevoExpediente.add(label_cedula, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 135, 62, 22));
        Panel_nuevoExpediente.add(txt_apellidos_expediente, new org.netbeans.lib.awtextra.AbsoluteConstraints(76, 104, 314, -1));
        Panel_nuevoExpediente.add(txt_cedula_expediente, new org.netbeans.lib.awtextra.AbsoluteConstraints(76, 136, 314, -1));

        btn_agregar_expediente.setText("Agregar");
        btn_agregar_expediente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_agregar_expedienteActionPerformed(evt);
            }
        });
        Panel_nuevoExpediente.add(btn_agregar_expediente, new org.netbeans.lib.awtextra.AbsoluteConstraints(319, 163, -1, -1));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel1.setText("Cliente");
        Panel_nuevoExpediente.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 56, -1, -1));

        jMenu1.setText("Archivo");

        Menu_archivo.setText("Cerrar");
        Menu_archivo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Menu_archivoActionPerformed(evt);
            }
        });
        jMenu1.add(Menu_archivo);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(Panel_nuevoExpediente, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(Panel_nuevoExpediente, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btn_agregar_expedienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_agregar_expedienteActionPerformed
        
        if(ui.guardaExamen(Integer.parseInt(txt_cedula_expediente.getText()))){
            ui.agregar_expediente(this);System.out.println("ENTRO AQUI");
        }else{
            JOptionPane.showMessageDialog(null, "Ya existe un usuario con esa cédula!!!");
        }
    }//GEN-LAST:event_btn_agregar_expedienteActionPerformed

    private void Menu_archivoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Menu_archivoActionPerformed
        this.setVisible(false);
        this.txt_apellidos_expediente.setText("");
        this.txt_cedula_expediente.setText("");
        this.txt_nombre_expediente.setText("");
    }//GEN-LAST:event_Menu_archivoActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(NuevoExpedienteFrame_express.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(NuevoExpedienteFrame_express.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(NuevoExpedienteFrame_express.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(NuevoExpedienteFrame_express.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new NuevoExpedienteFrame_express().setVisible(true);
            }
        });
    }

    public JPanel getPanel_nuevoExpediente() {
        return Panel_nuevoExpediente;
    }

    public JButton getBtn_agregar_expediente() {
        return btn_agregar_expediente;
    }

    public JLabel getLabel_apellidos() {
        return label_apellidos;
    }

    public JLabel getLabel_cedula() {
        return label_cedula;
    }

    public JLabel getLabel_nombre() {
        return label_nombre;
    }

    public JLabel getLabel_titulo() {
        return label_titulo;
    }

    public JTextField getTxt_apellidos_expediente() {
        return txt_apellidos_expediente;
    }

    public JTextField getTxt_cedula_expediente() {
        return txt_cedula_expediente;
    }

    public JTextField getTxt_nombre_expediente() {
        return txt_nombre_expediente;
    }        
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem Menu_archivo;
    private javax.swing.JPanel Panel_nuevoExpediente;
    private javax.swing.JButton btn_agregar_expediente;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JLabel label_apellidos;
    private javax.swing.JLabel label_cedula;
    private javax.swing.JLabel label_nombre;
    private javax.swing.JLabel label_titulo;
    private javax.swing.JTextField txt_apellidos_expediente;
    private javax.swing.JTextField txt_cedula_expediente;
    private javax.swing.JTextField txt_nombre_expediente;
    // End of variables declaration//GEN-END:variables
}
